package com.lhy.mymall.controller;

import com.github.pagehelper.PageInfo;
import com.lhy.mymall.common.ApiRestResponse;
import com.lhy.mymall.pojo.Product;
import com.lhy.mymall.request.ProductListReq;
import com.lhy.mymall.service.ProductService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author: 卢辉宇
 * @date: 2022/12/17 20:22
 * @description:
 */
@RestController
public class ProductController {

    @Resource
    ProductService productService;

    @PostMapping("/product/detail")
    public ApiRestResponse detail(Integer id){
        //调用service层的业务逻辑...
        Product product = productService.detail(id);

        return ApiRestResponse.success(product.getDetail());
    }

    @PostMapping("/product/list")
    public ApiRestResponse list(ProductListReq productListReq){
        //调用service层的列表业务逻辑...
        PageInfo pageInfo = productService.list(productListReq);

        return ApiRestResponse.success(pageInfo);
    }
}
